package sk.vrto.domain;

import javax.persistence.*;
import java.io.Serializable;

/**
 * User of the application.
 */
@Entity
@Table(name = "USERS")
public class User implements Serializable {

    @Id
    private String login;
    private String password;

    @OneToOne
    private EmailAccount emailAccount;

    /**
     * Creates a new user
     * @param login Login to the email applicaiton
     * @param password Password for the email application
     * @param emailAccount Bound email account
     */
    public User(String login, String password, EmailAccount emailAccount) {
        this.login = login;
        this.password = password;
        this.emailAccount = emailAccount;
    }

    public User() {
        // hibernate ctor
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public EmailAccount getEmailAccount() {
        return emailAccount;
    }

    public void setEmailAccount(EmailAccount emailAccount) {
        this.emailAccount = emailAccount;
    }

    @Override
    public String toString() {
        return "User{" +
                "login='" + login + '\'' +
                ", password='" + password + '\'' +
                ", emailAccount=" + emailAccount +
                '}';
    }
}
